package com.example.cmpe277stockdata.test;

import java.util.ArrayList;

import com.example.cmpe277stockdata.LandingActivity;
import com.example.cmpe277stockdata.NewsActivity;
import com.jayway.android.robotium.solo.Solo;

import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

public class InitialStockData extends
		ActivityInstrumentationTestCase2<LandingActivity> {
	
	private Solo solo;

	@SuppressWarnings("deprecation")
	public InitialStockData() {
		super("com.example.cmpe277stockdata",LandingActivity.class);
		// TODO Auto-generated constructor stub
	}
	
	protected void setUp() throws Exception{
		super.setUp();
		solo= new Solo(getInstrumentation(), getActivity());
	}
	
	/*public void testLogin(){
		solo.assertCurrentActivity("Check on the first activity", LandingActivity.class);
		solo.clickOnText("Login or Register");
		solo.enterText(0, "rachana");
		solo.enterText(1, "rachana1");
		solo.clickOnButton("Sign In");
	}*/
	
	public void testLanding(){
		solo.assertCurrentActivity("Check on the first activity", LandingActivity.class);
		solo.sleep(20000);
		//solo.clickInList(8);
		 ArrayList<View> list = solo.getCurrentViews();

	      for(int i = 0; i < list.size(); i++) {
	    	  //Clicks on the list item assert that the new activity is started
	         solo.clickInList(4,0);
	         solo.assertCurrentActivity("NewsActivity Class", NewsActivity.class);	         
	        }
	      solo.goBack();
	      solo.assertCurrentActivity("Check on the first activity", LandingActivity.class);
			solo.clickOnText("Login or Register");
			solo.enterText(0, "sowmya");
			solo.enterText(1, "sowmya");
			solo.clickOnButton("Sign In");
		}

	
}
